<template>
    <div>
        <img id="captcha2" @click="refresh()" style="width:100%;height:40px;vertical-align:middle;" :src="capSrc" alt="验证码">
    </div>
</template>


<script>

import axios from 'axios';
    export default {
        name: "captcha",
        data(){
            return{
                capSrc:'/captcha/',
            }
        },
      created() {
        this.refresh()
      },
      methods:{
            refresh() { //验证码刷新

                let time=new Date()   //以当前时间为唯一值,防止缓存
              axios.post('/api/captcha/?ser=user&time='+time).then(response =>{
                this.capSrc=response.data;
              })
                console.log("验证码刷新成功!");

            },
        }
    }
</script>

<style scoped>
  #captcha2{
    cursor: pointer;
  }
</style>